Published on

Performance Comparison WeScale vs MySQL

Authors

WeSQL WeScale is a database proxy that is compatible with MySQL. It supports read-write splitting without stale reads, connection pooling, and transparent failover. These features work together to improve application scalability, performance, security, and resilience. In this article, we will compare the performance of WeSQL WeScale and MySQL, and examine how these features affect throughput and latency. Let's get started!

For those in a hurry, here are the main findings:

  • Adding WeSQL WeScale as a proxy for MySQL may result in some extra network round trips, but as the workload increases, it can achieve the same throughput and latency as a direct connection to MySQL.
  • Due to connection multiplexing, WeSQL WeScale can maintain stable high throughput during high workloads, while MySQL's performance may be reduced due to excessive connection occupying memory in the buffer pool.
  • When the read-write-split feature is activated, WeSQL WeScale demonstrates linear throughput growth even after MySQL reaches its bottleneck, as the number of pressure testing threads gradually increases.
  • The additional memory consumption of WeSQL WeScale can be considered negligible compared to MySQL.
  • The CPU overhead introduced by WeSQL WeScale accounts for only about 1/3 of the total resource consumption. The cost-effectiveness of increasing QPS through read-write-splitting and horizontal scaling with WeSQL WeScale is higher compared to the cost-effectiveness of vertical scaling with MySQL.

Benchmarking WeSQL WeScale and MySQL

Environment

kubernetes version:1.26.3

Load balancer: slb.s2.small

Machine: 4C16G

SysBench: balanced read write workload

We have deployed a WeSQL WeScale cluster in Kubernetes. SysBench can connect to both VTGate and MySQL directly, allowing us to compare their performance. The MySQL cluster consists of one Leader and two Followers. VTTablet is deployed as a sidecar in the MySQL Pod. VTGate and SysBench are deployed in their respective Pods. Each Pod will have exclusive access to a 4-core 16GB cloud server.

MySQL vs WeSQL WeScale (With Read Write Split Disabled)

ThreadsWeSQL WeScale QPSWeSQL WeScale LatencyMySQL QPSMySQL Latency
4.002858.98139.774638.0186.20
8.004386.4182.217508.50106.48
166698.62238.589654.44165.67
258596.97290.4710968.65227.77
5011576.21431.3612440.1401.39
7512242.44611.3613055.7573.76
10012488.25798.4812998.67767.69
12512551.41389.3912772.81366.46
15012630.161579.1712351.891614.56
175128431745.5912024.31864.79
20012612.591972.611686.862132.42
read_write_split_disable_qps_latency.png

Some Observations:

  • When the sysbench thread count is low, WeSQL WeScale's throughput is lower than when directly connecting to MySQL. This is due to the introduction of additional network round trips. Deploying the application with VTGate can mitigate this issue. In most cases, the SQL queries in the business logic are more complex than SysBench, so the impact of the network is relatively lower in reality.
  • As the number of threads increases, the performance and throughput of WeSQL WeScale begins to reach, and even exceed, that of directly connecting to MySQL. This is because WeSQL WeScale supports connection multiplexing. With the same throughput, it creates fewer connections on the MySQL side, allowing MySQL to allocate more memory to the buffer pool.

During the testing process, we found that MySQL couldn't handle too many sysbench threads due to the limitation of max_connection. We had to modify the max_connection parameter in order to test with 200 sysbench threads. However, with max_connections set to 100 in MySQL, WeSQL WeScale can handle over 5000 sysbench threads (we are unable to increase the number of sysbench threads further due to memory constraints on the server).

The above test proves a point: introducing WeSQL WeScale as a proxy will not affect the throughput of the database. In high workload scenarios, it can even maintain throughput without decreasing as connections increase. WeSQL WeScale can help you avoid errors like 'too many connections'.

How about the resources introduced by WeSQL WeScale

ThreadsWeSQL WeScale CPU (m)WeSQL WeScale Memory (Mi)MySQL CPU (m)MySQL Memory (Mi)
44916.7430096.418036.7530146.91
810913.2530124.009685.5830154.8
1613206.7530140.2510240.530146.41
2513961.6630126.58969230161
5013820.1630131.589895.2530093.25
7514413.7530116.0810398.7530132.91
10014553.0830154.9110446.4130128.8
12514511.2430139.0010440.5830142.68
15014942.0830146.7510859.9130177.08
17515190.5030134.9110797.5830037
20015280.7530119.5011137.2530139.8
read_write_split_disable_cpu_memory.png

During our SysBench testing, we simultaneously measured the resource usage of the two:

  • The additional memory consumption of WeSQL WeScale can be considered negligible compared to MySQL.
  • WeSQL WeScale is expected to utilize approximately 1/3 more CPU resources.

MySQL vs WeSQL WeScale ( With Read Write Split Enable)

ThreadsWeSQL WeScale QPSWeSQL WeScale LatencyMySQL QPSMySQL Latency
42858.98139.774638.0186.2
84202.61190.125252.91152.18
166983.17228.978303.15192.53
259583.73260.5112807.06195.02
5012689.05393.7612631.39395.28
7515703.01476.5912642.1592.75
10017772.62560.712907.98773.19
12519049.49655.3713028957.99
15020509.19729.8612994.451152.22
17521289.84820.1212910.421352.38
20022398.34931.0812537.161531.23
read_write_split_enable_qps_latency.png

Some Observations:

  • When WeSQL WeScale enables Read-Write-Split, the QPS of the leader node is higher compared to when Read-Write-Split is not enabled. This is because a portion of the Read traffic is being routed to the follower node.
  • As the number of Sysbench threads continues to increase, MySQL's QPS will reach a bottleneck and cannot continue to grow, but due to contention, latency will continue to increase.
  • WeSQL WeScale's QPS can continue to grow, while latency is lower than MySQL, the QPS has almost doubled compared to before.

The above test proves a point: by introducing WeSQL WeScale as a proxy, it can scale horizontally and make use of follower node resources, resulting in improved read and write performance of the cluster.

How about the resources introduced by WeSQL WeScale

ThreadsWeSQL WeScale CPU (m)WeSQL WeScale Memory (Mi)MySQL CPU (m)MySQL Memory (Mi)
49313.5830147.918507.5830215.75
812382.0030123.7410054.830120.8
1614923.643013610851.9930120.75
2515933.0030090.11049130188.91
5016377.6630119.259986.5830179
7515982.9130193.919882.9130168.91
10016423.6830179.581018030198.58
12516628.913018210516.5830208.75
15016805.7530184.6810410.6630199.41
17517098.5830182.4910584.9130189.58
20017211.5030202.2510745.6630185.91
read_write_split_enable_cpu_memory.png
  • In all workload scenarios, the overall memory resource usage of the cluster is similar to MySQL, which demonstrates that WeSQL WeScale only requires a minimal amount of memory.
  • Even though the QPS has almost doubled, the additional CPU introduced by WeSQL WeScale is only 70% of MySQL's. This indicates that the cost-effectiveness of horizontal scaling through the read-write separation feature is relatively high.

Conclusion

In conclusion, introducing WeSQL WeScale as a proxy can significantly improve the scalability, performance, security, and resilience of a MySQL database. With read-write-splitting enabled, WeSQL WeScale can utilize follower node resources, resulting in improved read and write performance of the cluster. Furthermore, the overhead introduced by WeSQL WeScale is minimal, and its cost-effectiveness for increasing QPS through read-write-splitting and horizontal scaling is higher compared to the cost-effectiveness of vertical scaling with MySQL.